package com.ruoyi.crm.sale.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.sale.domain.CrmContractCheck;
import com.ruoyi.crm.sale.service.ICrmContractCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合同审核Controller
 * 
 * @author ruoyi
 * @date 2021-09-22
 */
@RestController
@RequestMapping("/crm/check")
public class CrmContractCheckController extends BaseController
{
    @Autowired
    private ICrmContractCheckService crmContractCheckService;

    /**
     * 查询合同审核列表
     */
    @PreAuthorize("@ss.hasPermi('crm:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmContractCheck crmContractCheck)
    {
        startPage();
        List<CrmContractCheck> list = crmContractCheckService.selectCrmContractCheckList(crmContractCheck);
        return getDataTable(list);
    }

    /**
     * 查询所有合同审核列表
     */
    @PreAuthorize("@ss.hasPermi('crm:check:list')")
    @GetMapping("/listAllData")
    public TableDataInfo listAllData(CrmContractCheck crmContractCheck)
    {
        List<CrmContractCheck> list = crmContractCheckService.selectCrmContractCheckList(crmContractCheck);
        return getDataTable(list);
    }

    /**
     * 导出合同审核列表
     */
    @PreAuthorize("@ss.hasPermi('crm:check:export')")
    @Log(title = "合同审核", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CrmContractCheck crmContractCheck)
    {
        List<CrmContractCheck> list = crmContractCheckService.selectCrmContractCheckList(crmContractCheck);
        ExcelUtil<CrmContractCheck> util = new ExcelUtil<CrmContractCheck>(CrmContractCheck.class);
        return util.exportExcel(list, "合同审核数据");
    }

    /**
     * 获取合同审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('crm:check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(crmContractCheckService.selectCrmContractCheckById(id));
    }

    /**
     * 新增合同审核
     */
    @PreAuthorize("@ss.hasPermi('crm:check:add')")
    @Log(title = "合同审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmContractCheck crmContractCheck)
    {
        return toAjax(crmContractCheckService.insertCrmContractCheck(crmContractCheck));
    }

    /**
     * 修改合同审核
     */
    @PreAuthorize("@ss.hasPermi('crm:check:edit')")
    @Log(title = "合同审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmContractCheck crmContractCheck)
    {
        return toAjax(crmContractCheckService.updateCrmContractCheck(crmContractCheck));
    }

    /**
     * 删除合同审核
     */
    @PreAuthorize("@ss.hasPermi('crm:check:remove')")
    @Log(title = "合同审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crmContractCheckService.deleteCrmContractCheckByIds(ids));
    }
}
